Skip to content

fix(trending-challenge-rewards): inline sol_reward_disbursements, drop dropped view#58

Merged
raymondjacobson merged 1 commit into
mainfrom
fix/tcr-drop-challenge-disbursements-view
Jun 8, 2026
Merged

fix(trending-challenge-rewards): inline sol_reward_disbursements, drop dropped view#58
raymondjacobson merged 1 commit into
mainfrom
fix/tcr-drop-challenge-disbursements-view

Conversation

@raymondjacobson

Copy link
Copy Markdown
Member

Summary

The trending disburser's summary queries (getChallengesDisbursementsUserbanks and getChallengesDisbursementsUserbanksFriendly in queries.ts) leftJoin the v_challenge_disbursements compatibility view. That view was dropped in api migration 0212 (the API routes were refactored to inline the join — see api/v1_challenges_disbursements.go). So every /disburse run now throws in the post-payout summary step:

relation "v_challenge_disbursements" does not exist  (42P01)

Payouts still succeed (they happen before the summary), but the exception fires before chat.postMessage, so the Slack confirmation table never posts.

Change

Join sol_reward_disbursements directly on (challenge_id, specifier) for slot, in both queries. sol_reward_disbursements has exactly one row per (challenge_id, specifier), so the slot resolution is identical. The dropped view's only extra was a recipient_eth_address → users join to resolve user_id, which these queries never used — they already join users via user_challenges.user_id.

No other references to the view remain in the app.

Why this happened (context)

Surfaced while manually disbursing the corrected 2026-06-05 trending/underground winners. All 23 rows paid out fine, but no Slack summary posted because of this 42P01. Recreating the view is a viable stopgap, but it resurrects something the api repo deliberately dropped — this decouples the disburser from it for good.

Test plan

  • String-literal table swap inside .leftJoin(table, joinFn) — structurally identical, type-unchanged (full monorepo typecheck not run here due to local dep skew; no errors reference queries.ts).
  • On next /disburse <date>, the summary query runs and the Slack table posts (no 42P01).

🤖 Generated with Claude Code

…p dropped view

The disburser's summary queries (getChallengesDisbursementsUserbanks and
getChallengesDisbursementsUserbanksFriendly) left-joined the
v_challenge_disbursements compatibility view, which the api repo dropped in
migration 0212 (its routes were refactored to inline the join). Every
/disburse run then threw `relation "v_challenge_disbursements" does not
exist` (42P01) in the post-disbursement summary, so the Slack confirmation
never posted -- even though payouts succeeded.

Join sol_reward_disbursements directly on (challenge_id, specifier) for the
slot. The table has one row per disbursement, so the slot resolution is
unchanged; the prior view only added a recipient->user join that these
queries never used (they already join users via user_challenges.user_id).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@raymondjacobson raymondjacobson merged commit ada60f9 into main Jun 8, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant